#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
struct student
{
	char id[6];
	char name[20];
	int per;
};
void *test(void *arg);
int main()
{
	struct student t1={"10086","中国联通",110};
	pthread_t p=-1;
	if(pthread_create(&p,NULL,test,&t1)!=0){perror("创建新线程失败:");return -1;}
	pthread_detach(p);
	int n=5;
	while(n--)
	{
		printf("我是主线程");
		printf("%#lx\n",pthread_self());
		sleep(1);

	}
	return 0;
}
void *test(void *arg)
{
	struct student t1=*(struct student*)arg;
	int n=10;
	while(n--)
	{
		printf("我是分支线程");
		printf("%#lx\n",pthread_self());
		printf("%s,,,%s,,,%d\n",t1.id,t1.name,t1.per);
		sleep(1);
		//退出线程
		//pthread_exit(NULL);
		//分离线程
	}
	pthread_exit(NULL);
}

